package wangwenjun.phase2.concurrencypattern.singlethreadexecution.demo01;

import java.util.concurrent.TimeUnit;

/**
 * @author ChangLiang
 * @date 2020/6/12
 */
public class PassengerV2 extends Thread {

    private final FlightSecurityV2 flightSecurity;
    private final String idCard;
    private final String boardingPass;

    public PassengerV2(FlightSecurityV2 flightSecurity,
                       String idCard, String boardingPass) {
        this.flightSecurity = flightSecurity;
        this.idCard = idCard;
        this.boardingPass = boardingPass;
    }

    @Override
    public void run() {
        while (true) {
            // 某个旅客不断地过安检
            flightSecurity.pass(idCard, boardingPass);
            try {
                TimeUnit.MILLISECONDS.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}